<template>
	<div class="settings">
		<el-form :model="data" label-position="top" label-width="50px">
			<el-form-item label="左侧图片:">
				<div class="imgbox" @click=";(photo = true), key++">
					<!-- 图片框架 -->
					<el-image class="img" :src="'https://webgallery.oss-cn-beijing.aliyuncs.com/' + data?.web?.img" fit="contain">
						<template #placeholder>
							<div class="image-slot">
								<el-icon>
									<Plus />
								</el-icon>
							</div>
						</template>
						<template #error>
							<div class="image-slot">
								<el-icon>
									<Plus />
								</el-icon>
							</div>
						</template>
					</el-image>
				</div>
			</el-form-item>
			<el-form-item label="背景(整体):">
				<el-color-picker v-model="data.web.background" show-alpha :predefine="data.predefineColors" />
				<el-input v-model="data.web.background" class="rgbinput" placeholder="Please Input" />
			</el-form-item>
			<el-form-item label="背景(局部):">
				<el-color-picker v-model="data.web.Contentbackground" show-alpha :predefine="data.predefineColors" />
				<el-input v-model="data.web.background" class="rgbinput" placeholder="Please Input" />
			</el-form-item>
			<el-form-item label="默认文字颜色：">
				<el-color-picker v-model="data.web.color" show-alpha :predefine="data.predefineColors" />
				<el-input v-model="data.web.color" class="rgbinput" placeholder="Please Input" />
			</el-form-item>

			<el-form-item label="文本:">
				<el-radio-group class="i18nradio" v-model="radio">
					<el-radio-button label="zh" @click=";($i18n.locale = 'zh'), key++">简体中文</el-radio-button>
					<el-radio-button label="en" @click=";($i18n.locale = 'en'), key++">English</el-radio-button>
				</el-radio-group>
				<tiptap v-if="radio == 'zh'" :content="data.web.content[radio]" @send-data="senddata" :height="'200'" :key="key" :editable="true" />
				<tiptap v-if="radio == 'en'" :content="data.web.content[radio]" @send-data="senddata" :height="'200'" :key="key" :editable="true" />
				<!-- <el-input @input="Contentedited" v-model="form.title" /> -->
			</el-form-item>
		</el-form>
		<photoalbum v-if="photo" @send-img="image" :key="key"></photoalbum>
	</div>
</template>
<script>
	// 这里要把index 和list 传给组件  组件修改时 实时传回
	import Tiptap from '@/components/Tiptap.vue'
	import photoalbum from '@/components/photoalbum.vue'
	export default {
		components: {
			Tiptap,
			photoalbum,
		},
		props: ['data'],
		data() {
			return {
				radio: this.$i18n.locale,
				photo: false,
				key: 0,
			}
		},
		methods: {
			image(img) {
				this.data.web.img = img
				this.photo = false
			},
			senddata(content) {
				this.data.web.content[this.radio] = content
			},
		},
		mounted() {
			// this.data.web['content']['zhongguo'] = '999'
			// this.data['ceshi'] = '新增的无需设置  直接在这里增加一个属性即可  拖拽页就没那么麻烦了'
		},
	}
</script>
<style scoped>
	.settings .rgbinput {
		width: 150px;
		margin-left: 10px;
	}
	.imgbox {
		border-radius: 4px;

		min-width: 100px;
		height: 100px;
	}
	.imgbox .img {
		border-radius: 4px;
		height: 100px;
		max-width: 430px;
	}
	.imgbox .image-slot {
		border: 1px solid #c8c9cc;
		border-radius: 4px;
		width: 100px;
		height: 100px;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #c8c9cc;
		font-size: 30px;
	}
	.i18nradio {
		width: 100%;
		margin-bottom: 10px;
		align-items: center;
		justify-content: center;
	}
</style>
